package com.ss.android.article.base.feature.update.b;

import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bytedance.common.utility.UIUtils;
import com.ss.android.account.Spipe;
import com.ss.android.action.b.FeedViewHolder;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.base.feature.feed.vh.CardViewPools;
import com.ss.android.article.base.feature.update.a.UserInfo;
import com.ss.android.article.base.feature.update.a.e;
import com.ss.android.article.base.feature.update.activity.g;
import com.ss.android.article.base.feature.update.activity.t.a;
import com.ss.android.article.base.ui.DiggLayout;
import com.ss.android.article.base.ui.EllipsisTextView;
import com.ss.android.article.base.ui.PriorityLinearLayout;
import com.ss.android.article.base.ui.DiggAnimationView;
import com.ss.android.article.base.utils.b.LinkSpan;
import com.ss.android.article.base.utils.b.b;
import com.ss.android.article.common.SingleTypeViewPool;
import com.ss.android.common.lib.MobClickCombiner;
import com.ss.android.image.AsyncImageView;
import com.ss.android.image.loader.ImageLoader;
import com.ss.android.newmedia.a.TimeFormatter;
import java.util.concurrent.atomic.AtomicBoolean;

public final class d extends FeedViewHolder implements a {
    public static final class d$a {
        protected final g a;

        public d$a(g arg1) {
            this.a = arg1;
        }

        public final void a(UserInfo arg2, String arg3) {
            if((this.a.isViewValid()) && arg2 != null) {
                if(!TextUtils.isEmpty(((CharSequence)arg3))) {
                    this.a.a(arg3);
                }

                AppData.aK();
            }
        }
    }

    public ImageLoader A;
    private static int[] B = new int[]{16, 14, 18, 20};
    private View C;
    private AsyncImageView D;
    private ImageView E;
    private TextView F;
    private TextView G;
    private ImageView H;
    private PriorityLinearLayout I;
    private TextView J;
    private View K;
    private TextView L;
    private TextView M;
    private EllipsisTextView N;
    private ImageView O;
    private DiggAnimationView P;
    private Spipe Q;
    private TimeFormatter R;
    private int S;
    private String T;
    private AtomicBoolean U;
    private int V;
    private b W;
    private View.OnClickListener X;
    private View.OnClickListener Y;
    private View.OnClickListener Z;
    private View.OnClickListener aa;
    private View.OnClickListener ab;
    private View.OnLongClickListener ac;
    DiggLayout o;
    TextView p;
    public TextView q;
    TextView r;
    Activity s;
    AppData t;
    public com.ss.android.article.base.feature.update.a.d u;
    public e v;
    final d$a w;
    int x;
    boolean y;
    boolean z;

    public d(Activity arg3, View arg4, d$a arg5, DiggAnimationView arg6, int arg7, String arg8, AtomicBoolean arg9, boolean arg10, ImageView arg11) {
        this.X = new com.ss.android.article.base.feature.update.b.e(this);
        this.Y = new com.ss.android.article.base.feature.update.b.f(this);
        this.Z = new com.ss.android.article.base.feature.update.b.g(this);
        this.aa = new com.ss.android.article.base.feature.update.b.h(this);
        this.ab = new i(this);
        this.ac = new j(this);
        new com.ss.android.article.base.feature.update.b.l(this);
        this.w = arg5;
        this.Q = Spipe.inst();
        this.t = AppData.getInstance();
        this.s = arg3;
        this.s.getResources();
        this.R = new TimeFormatter(((Context)arg3));
        this.S = this.t.mFontSizePref;
        this.x = arg7;
        this.T = arg8;
        this.S = this.t.mFontSizePref;
        this.U = arg9;
        this.y = true;
        UpdateItemMgr.getInstance(this.s);
        this.z = arg10;
        this.P = arg6;
        this.O = arg11;
        new SingleTypeViewPool(9);
        LayoutInflater.from(this.s);
        this.V = this.s.getResources().getDimensionPixelSize(com.ss.android.article.browser.R.dimen.update_avatar_size);
        this.C = arg4.findViewById(com.ss.android.article.browser.R.id.root);
        this.D = arg4.findViewById(com.ss.android.article.browser.R.id.avatar);
        this.E = arg4.findViewById(com.ss.android.article.browser.R.id.mark_v);
        this.F = arg4.findViewById(com.ss.android.article.browser.R.id.acq);
        this.o = arg4.findViewById(com.ss.android.article.browser.R.id.acx);
        this.o.setDiggAnimationView(this.P);
        arg4.findViewById(com.ss.android.article.browser.R.id.name_layout);
        this.G = arg4.findViewById(com.ss.android.article.browser.R.id.acs);
        this.p = arg4.findViewById(com.ss.android.article.browser.R.id.verified_text);
        this.H = arg4.findViewById(com.ss.android.article.browser.R.id.verified_img);
        this.I = arg4.findViewById(com.ss.android.article.browser.R.id.acr);
        this.J = arg4.findViewById(com.ss.android.article.browser.R.id.act);
        this.K = arg4.findViewById(com.ss.android.article.browser.R.id.acu);
        this.L = arg4.findViewById(com.ss.android.article.browser.R.id.time);
        this.M = arg4.findViewById(com.ss.android.article.browser.R.id.acw);
        this.q = arg4.findViewById(com.ss.android.article.browser.R.id.acv);
        arg4.findViewById(com.ss.android.article.browser.R.id.content_layout);
        this.N = arg4.findViewById(com.ss.android.article.browser.R.id.content);
        this.r = arg4.findViewById(com.ss.android.article.browser.R.id.btn_view_all);
        arg4.findViewById(com.ss.android.article.browser.R.id.margin_stub);
        this.C.setOnClickListener(this.X);
        this.G.setOnClickListener(this.Z);
        this.D.setOnClickListener(this.Y);
        this.O.setOnClickListener(this.aa);
        this.o.setOnClickListener(this.ab);
        this.N.setOnLongClickListener(this.ac);
        this.N.setOnClickListener(this.X);
    }

    public final void a(boolean arg3) {
        if(arg3) {
            this.q.setVisibility(View.VISIBLE);
        }
        else {
            this.q.setVisibility(View.GONE);
        }
    }

    public final void a(e arg15) {
        CardViewPools v5 = null;
        int v4 = -3;
        int v9 = View.GONE;
        if(arg15 != null && arg15.a != null) {
            this.U.get();
            this.v = arg15;
            this.u = (com.ss.android.article.base.feature.update.a.d) arg15.a;
            Object v0 = AppData.getInstance().bo.get(Long.valueOf(this.u.i));
            if(v0 != null && (((com.ss.android.article.common.entity.a.a)v0).a) && this.u != null) {
                this.u.a = ((com.ss.android.article.common.entity.a.a)v0).a;
            }

            if(this.u.o != null) {
                this.D.setUrl(this.u.o.avatarUrl);
            }

            int v0_1 = !this.z || this.u.o == null || this.u.o.role != 1 ? 0 : 1;
            ImageView v2 = this.E;
            int v1 = v0_1 != 0 ? 0 : v9;
            UIUtils.setVisibility(((View)v2), v1);
            if(v0_1 != 0) {
                UIUtils.setLayoutParams(this.E, this.V, v4);
                UIUtils.setLayoutMargins(this.E, v4, v4, 0, ((int) UIUtils.dp2px(this.s, -5.5f)));
                this.E.setImageResource(com.ss.android.article.browser.R.drawable.uo);
            }

            if(!android.support.design.a.isTextEmpty(arg15.d)) {
                UIUtils.setVisibility(this.F, 0);
                this.F.setText(arg15.d);
                UIUtils.setVisibility(this.K, v9);
            }
            else {
                UIUtils.setVisibility(this.K, 0);
                UIUtils.setVisibility(this.F, v9);
                if(!android.support.design.a.isTextEmpty(this.u.n)) {
                    UIUtils.setVisibility(this.M, 0);
                    this.M.setText(this.u.n);
                }
                else {
                    UIUtils.setVisibility(this.M, v9);
                }

                this.L.setText(this.R.a(arg15.a.s * 1000));
            }

            android.support.design.a.a(this.I, this.A, v5);
            if(this.u.o != null) {
                this.G.setText(this.u.o.screenName);
                if(!this.u.o.userVerified || (TextUtils.isEmpty(this.u.o.verifiedReason))) {
                    this.p.setVisibility(v9);
                    this.H.setVisibility(v9);
                }
                else {
                    this.p.setVisibility(View.VISIBLE);
                    this.H.setVisibility(View.VISIBLE);
                    this.p.setText(this.u.o.verifiedReason);
                    this.p.post(new n(this));
                }

                android.support.design.a.a(this.s, this.A, this.u.o.authorBadge, ((int) UIUtils.dp2px(this.s, 13f)), this.I, v5, this.s.getResources().getDimensionPixelSize(com.ss.android.article.browser.R.dimen.by));
            }

            if(!android.support.design.a.isTextEmpty(this.u.l)) {
                UIUtils.setVisibility(this.J, 0);
                this.J.setText(this.u.l);
            }
            else {
                UIUtils.setVisibility(this.J, v9);
            }

            if(!android.support.design.a.isTextEmpty(this.u.k)) {
                if(this.W == null) {
                    this.W = new m(this, this.s);
                }

                this.N.setText(TextUtils.concat(new CharSequence[]{LinkSpan.processContentUrl(this.s, this.u.k, this.W)}), TextView.BufferType.SPANNABLE);
                this.N.setMovementMethod(new LinkSpan.a(this.s));
                UIUtils.setVisibility(this.N, 0);
            }
            else {
                UIUtils.setVisibility(this.N, v9);
            }

            this.o.setSelected(this.u.a);
            if(this.u.b == 0) {
                this.o.setText(com.ss.android.article.browser.R.string.update_digg);
            }
            else {
                this.o.setText(UIUtils.a(this.u.b));
            }

            EllipsisTextView v1_1 = this.N;
            int v2_1 = 2;
            v0_1 = this.S;
            v0_1 = v0_1 < 0 || v0_1 >= B.length ? B[0] : B[v0_1];
            v1_1.setTextSize(v2_1, ((float)v0_1));
            this.N.setMaxLines(2147483647);
            this.N.setEllipsize(((TextUtils.TruncateAt)null));
        }
    }

    public final void a(UserInfo arg5, int arg6) {
        if(this.s != null && arg5 != null && arg5.userId > 0) {
            if(arg6 == 1) {
                if(this.Q.isLogin) {
                    this.a("click_digger");
                }
                else {
                    this.a("logoff_click_digger");
                }
            }
            else if(arg6 == 2) {
                if(this.Q.isLogin) {
                    this.a("click_replier");
                }
                else {
                    this.a("logoff_click_replier");
                }
            }

            AppData.aK();
        }
    }

    final void a(String arg3) {
        MobClickCombiner.onEvent(this.s, this.T, arg3);
    }
}

